package com.potenza.training.interview.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.interview.dao.InterviewReplyDao;
import com.potenza.training.interview.entity.InterviewReplyEntity;
import com.potenza.training.interview.service.InterviewReplyService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("interviewReplyService")
public class InterviewReplyServiceImpl extends ServiceImpl<InterviewReplyDao, InterviewReplyEntity> implements InterviewReplyService {

    @Autowired
    InterviewReplyDao interviewReplyDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InterviewReplyEntity> page = this.page(
                new Query<InterviewReplyEntity>().getPage(params),
                new QueryWrapper<InterviewReplyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
        public InterviewReplyEntity findByUid(Integer id, Integer uid) {
        QueryWrapper<InterviewReplyEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(InterviewReplyEntity::getInvitationId,id);
        queryWrapper.lambda().eq(InterviewReplyEntity::getUid,uid);
        return interviewReplyDao.selectOne(queryWrapper);
    }

    @Override
    public InterviewReplyEntity findReplybyInvitationId(Integer invitationId) {

        QueryWrapper<InterviewReplyEntity> interviewReplyEntityQueryWrapper = new QueryWrapper<>();
        interviewReplyEntityQueryWrapper.lambda().eq(InterviewReplyEntity::getInvitationId,invitationId);


        return interviewReplyDao.selectOne(interviewReplyEntityQueryWrapper);
    }

}